//
//  ReviewManager.m
//  DangoLine
//
//  Created by Venom on 12-1-16.
//  Copyright (c) 2012年 Lonicera Studio. All rights reserved.
//

#import "ReviewManager.h"
#import "handle.h"

@implementation ReviewManager

static ReviewManager *_sharedReview = nil;
+ (ReviewManager *)sharedReview
{
	@synchronized([ReviewManager class]) {
		if (!_sharedReview)
		{
			[[self alloc] init];
		}

		return _sharedReview;
	}

	return nil;
}

+ (id)alloc
{
	@synchronized([ReviewManager class]) {
		NSAssert(_sharedReview == nil, @"Attempted to allocate a second instance of a singleton.");
		_sharedReview = [super alloc];
		return _sharedReview;
	}

	return nil;
}

- (void)reviewFor:(int)appleID
{
	UIAlertView *alert;

	m_appleID = appleID;
	if (g_FlagChinese)
	{
		alert = [[UIAlertView alloc] initWithTitle:@"是否感觉正中红心呢"
		    message:@"  如果您觉得丘比特的冒险故事有爱并且有趣，希望您能用一点点时间来为我们的游戏写下您宝贵的评论。您的支持将是我们改进和进步的动力，谢谢！"
		    delegate:self
		    cancelButtonTitle:@"不想评～"
		    otherButtonTitles:@"现在就去评评看～", nil];
	}
	else
	{
		alert = [[UIAlertView alloc] initWithTitle:@"Rate LoveCupid"
		    message:@"If you enjoy this game,would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!"
		    delegate:self
		    cancelButtonTitle:@"No,Thanks"
		    otherButtonTitles:@"Rate It Now", nil];
	}
	[alert show];
	[alert release];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
	if (buttonIndex == 1)
	{
		NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d", m_appleID];
		[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
	}
}

@end